﻿using Microsoft.Phone.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Net;
using Microsoft.Phone.Net.NetworkInformation;

namespace WP8.EmpezandoComunicacion.Pages
{
    public partial class NetworkInformationPage : PhoneApplicationPage
    {
        public NetworkInformationPage()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            DeviceNetworkInformation.NetworkAvailabilityChanged += DeviceNetworkInformation_NetworkAvailabilityChanged;

            this.txtCellularMobileOperator.Text = DeviceNetworkInformation.CellularMobileOperator.ToString();
            this.txtIsCellularDataEnabled.Text = DeviceNetworkInformation.IsCellularDataEnabled.ToString();
            this.txtIsCellularDataRoamingEnabled.Text = DeviceNetworkInformation.IsCellularDataRoamingEnabled.ToString();
            this.txtIsNetworkAvailable.Text = DeviceNetworkInformation.IsNetworkAvailable.ToString();
            this.txtIsWiFiEnabled.Text = DeviceNetworkInformation.IsWiFiEnabled.ToString();


            base.OnNavigatedTo(e);
        }

        private void DeviceNetworkInformation_NetworkAvailabilityChanged(object sender, NetworkNotificationEventArgs e)
        {
            this.txtNetworkAvailability.Text = e.NotificationType.ToString();
        }
    }
}